﻿using System;
using PrismicIOAPI.Web.Common.UI;
using PrismicIOAPI.Web.UI;

namespace PrismicIOAPI.Usage.Example.aspx
{
    public partial class _default : PrismicPage
    {
        protected override void BindControls()
        {
            PageDocumentList = null;
            DataSource = String.Format( PrismicQuery.SEARCH_BY_TYPE , "default" );
            if( PageDocumentList == null || PageDocumentList.Count == 0 )
            {
                return;
            }
            int i, sz;
            sz = PageDocumentList.Count;
            if( sz > 0 )
            {
                prismic.Api.Document singleDocument = PageDocumentList[ 0 ];
                string channelName = GetText( singleDocument , "ChannelName" );
                ltrlChannelName.Text = "Channel Name: " + channelName;
                string creatorNames = GetText( singleDocument , "CreatorNames" );
                ltrlCreatorNames.Text = "Channel Creator Names: " + creatorNames;
                string subscribersCount = GetText( singleDocument , "SubscribersCount" );
                ltrlSubscribersCount.Text = "Total Subscribers Till Date: " + subscribersCount;
                string totalViewCount = GetText( singleDocument , "TotalViewCount" );
                ltrlTotalViewCount.Text = "Total View Count: " + totalViewCount;
                string description = GetHTML( singleDocument , "Description" );
                ltrlDescription.Text = description;
            }
        }
    }
}